<?php
// +----------------------------------------------------------------------
// | snake
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 http://baiyf.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: NickBai <1902822973@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\model\NodeModel;
use  think\Cache;

class Index extends Base
{
    public function index()
    {
        // 获取权限菜单
        $node = new NodeModel();
        $menuArr = $node->getMenu(session('rule'));
        foreach ($menuArr[0]['child'] as $k => $v) {
            if ($v['node_name'] == '节点管理') {
                unset($menuArr[0]['child'][$k]);
            }
        }
        $this->assign([
            'menu' => $menuArr
        ]);

        return $this->fetch('/index');
    }

    /**
     * 后台默认首页
     * @return mixed
     */
    public function indexPage()
    {
        return $this->fetch('index');
    }

    public function statistics()
    {
        $time = date('Y-m-d', time());
        $num = Cache::get($time);
        return json(['num' => $num]);
    }
}
